package com.example.mapper;

import com.example.entity.HealthRecord;
import com.example.entity.SocialMemo;
import org.apache.ibatis.annotations.*;

import java.util.List;
@Mapper
public interface SocialMemoMapper {

    @Insert("INSERT INTO social_memos (user_id, friend_name, birthday, event_description, event_time) " +
            "VALUES (#{userId}, #{friendName}, #{birthday}, #{eventDescription}, #{eventTime})")
    int insertSocialMemo(SocialMemo memo);

    @Delete("DELETE FROM social_memos WHERE memo_id = #{memoId}")
    int deleteSocialMemoById(Integer memoId);

    @Update("UPDATE social_memos SET friend_name = #{friendName}, birthday = #{birthday}, " +
            "event_description = #{eventDescription}, event_time = #{eventTime} WHERE memo_id = #{memoId}")
    int updateSocialMemo(SocialMemo memo);

    @Select("SELECT * FROM social_memos WHERE user_id = #{userId} ORDER BY event_time ASC")
    List<SocialMemo> getSocialMemosByUserId(Integer userId);
}
